package com.bookmarket.dao;

import com.bookmarket.entity.Custom;
import com.bookmarket.entity.Mess;
import com.bookmarket.entity.Order_Book;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * LLOrderMapper
 *
 * @author 李亮
 * @date 2018/1/3
 */
@Repository("/orderDao")
public interface LLOrderMapper {

    public Order_Book getord(int id);
    public List<Map> getOrder(Map<String, Object> cond);

    @Select("   SELECT  C.*,D.* from (tb_order_book C INNER JOIN tb_order A   on  C.order_id=A.id)\n" +
            "        INNER JOIN  tb_book D ON D.id = c.book_id WHERE A.id=#{id}  order by A.createTime desc ")
    public List<Map>  getOrder_Book(int id);

    public List<Map> getOrder2(Map<String, Object> cond);
    @Select("    SELECT  count(1) from (tb_order A INNER JOIN tb_order_book C on  C.order_id=A.id) INNER JOIN  tb_book D ON D.id = c.book_id WHERE A.custom_id=#{id}")
    public int getcount(Map<String, Object> cond);
    @Delete("delete  from tb_order_book  where id=#{id}")
    public void dell(int id);
    @Insert("insert  into tb_mess (score,messWord,custom_id,book_id)values(#{score},#{messWord},#{custom.id},#{book.id})")
    public void addmess(Mess mess);
    @Select("select book_id from tb_order_book where order_id=#{id}")
    public int sel(int id);
   public List<Mess> getmess(Map<String, Object>  map);
    @Select("select count(1) from tb_mess where custom_id=#{id}")
    public int getcoun(Map<String, Object>  map);
    @Delete("delete  from tb_mess where id=#{id}")
    public void dellmess(int id);
    @Update("update tb_custom set  realName =#{realName},phone=#{phone},email=#{email} where id=#{id}")
    public void updatecus(Custom custom);
    @Update("update tb_order set  status=#{1} where id=#{0}")
    public void update(int id,int stu);
}